﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

//Write a program that finds the maximal increasing sequence in an array. Example: {3, 2, 3, 4, 2, 2, 4}  {2, 3, 4}.

namespace _05MaxIncreasingSequence
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.Write("Size of array:");
            string strArraySize = Console.ReadLine();
            int arraySize = int.Parse(strArraySize);
            int[] array = new int[arraySize];
            for (int i = 0; i < arraySize; i++)
            {
                Console.Write("array[{0}]", i);
                string strValue = Console.ReadLine();
                array[i] = int.Parse(strValue);
            }
            Console.WriteLine("The array looks like this:");
            foreach (var item in array)
            {
                Console.Write(item + " ");
            }
            //int[] array = { 2, 3, 4, 5, 3, 2, 3, 2, 3, 2, 1, 3, 2, 1, 2, 3, 4, 5, 6 ,7};
            Console.WriteLine();
            int currentSequence = 0;
            int bestSequence = 0;
            int bestElement = 0;
            for (int i = 0; i < array.Length - 1; i++)
            {
                if (array[i] < array[i + 1])
                {
                    currentSequence++;
                }
                else
                {
                    currentSequence = 1;
                }
                if (currentSequence > bestSequence)
                {
                    bestSequence = currentSequence;
                    bestElement = i;
                }
            }
            Console.WriteLine("The longest sequence of incresing elements is:");
            for (int i = bestElement - bestSequence + 2; i < bestElement + 2 ; i++)
            {
                Console.Write(array[i] + " ");
            }
        }
    }
}
